package com.cl.pile.rule.filter;

import java.math.BigDecimal;

/**
 * @author chenyitao
 * @date 2021/4/20
 */
public class NotEqFilterOperation implements IFilterOperation {
    @Override
    public boolean filterMatch(Object value, String matchValue) {
        if (value == null && matchValue == null) {
            return true;
        }
        String numRegex = "-*\\d+(\\.\\d+)*";
        if (String.valueOf(value).matches (numRegex) && matchValue.matches(numRegex)) {
            BigDecimal num1 = new BigDecimal(String.valueOf(value));
            BigDecimal num2 = new BigDecimal(matchValue);
            return num1.compareTo(num2) != 0;
        } else {
            return !String.valueOf(value).equals(matchValue);
        }
    }

    @Override
    public String filterName() {
        return "不等于";
    }
}
